package com.xx.springboot.DataStructure.LeetCode.Sort;

import java.util.Arrays;

/**
 * Created by xiaoxiunique on 2018-10-18.
 */
public class merge {


    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        int[] arr = new int[10];

        for (int i = 0 ; i < m ; i ++) {
            arr[nums1[i]] = ++arr[nums1[i]];
        }

        for (int i = 0 ; i < n ; i ++) {
            arr[nums2[i]] = ++arr[nums2[i]];
        }

        int index = 0;
        for (int i = 0 ; i < (m + n) ; i ++) {
            if(arr[i] == 0){
                nums1[index] = 0;
            }
            for (int j = 0 ; j < arr[i] ; j ++) {
                nums1[index] = i;
                index++;
            }
        }
        System.out.println(Arrays.toString(nums1));
    }


    public static void main(String[] args) {
        merge(new int[]{1, 2, 3, 0, 0, 0, 0, 0}, 3, new int[]{1, 2} , 2);
    }
}
